import sys
from PyQt5.QtWidgets import QApplication
from qfluentwidgets import FluentWindow, FluentIcon, setTheme, Theme, NavigationItemPosition, FluentTranslator

# 导入所有界面
from interfaces.home import HomeInterface
from interfaces.data_generator import DataGeneratorInterface
from interfaces.planning import PlanningInterface
from interfaces.stats import StatsInterface
from interfaces.batch import BatchInterface
from interfaces.clear import ClearInterface
from animation_interface import AnimationInterface
from interfaces.quadrant import QuadrantInterface  # 添加这行

class MainWindow(FluentWindow):
    def __init__(self):
        super().__init__()
        self.initWindow()

    def initWindow(self):
        # 改大窗口默认尺寸以适应展开的侧边栏
        self.resize(1615, 1155)  # 修改默认窗口大小
        self.setMinimumWidth(1200)  # 设置最小宽度
        self.setMinimumHeight(800)  # 设置最小高度
        self.setWindowTitle('低空多智能体分层路径规划实验平台')
        
        # 修改导航栏样式
        self.navigationInterface.setExpandWidth(268)
        self.navigationInterface.setMinimumWidth(48)
        
        # 直接给导航栏设置样式
        nav_style = '''
            QWidget {
                background: rgba(40, 44, 52, 0.95);
            }
            QPushButton {
                padding: 20px 30px;
                font-size: 26px !important;
                icon-size: 32px;
                qproperty-iconSize: 32px 32px;
                font-weight: bold;
                margin: 8px;
                border-radius: 10px;
                text-align: left;
            }
            QPushButton:hover {
                background: rgba(255, 255, 255, 0.1);
            }
            QPushButton:checked {
                background: rgba(255, 255, 255, 0.15);
            }
        '''
        
        self.navigationInterface.setStyleSheet(nav_style)
        
        setTheme(Theme.DARK)
        self._setup_interfaces()
        self._setup_navigation()

    def _setup_interfaces(self):
        # 创建所有界面实例
        self.homeInterface = HomeInterface(self)
        self.dataGeneratorInterface = DataGeneratorInterface(self)
        self.mathInterface = QuadrantInterface(self)  # 修改这行
        self.planningInterface = PlanningInterface(self)
        self.animationInterface = AnimationInterface(self)
        self.batchInterface = BatchInterface(self)  # 添加这行
        self.statsInterface = StatsInterface(self)
        self.clearInterface = ClearInterface(self)

        # 设置对象名称
        self.homeInterface.setObjectName('homeInterface')
        self.dataGeneratorInterface.setObjectName('dataGeneratorInterface')
        self.mathInterface.setObjectName('mathInterface')
        self.planningInterface.setObjectName('planningInterface')
        self.animationInterface.setObjectName('animationInterface')
        self.batchInterface.setObjectName('batchInterface')  # 添加这行
        self.statsInterface.setObjectName('statsInterface')
        self.clearInterface.setObjectName('clearInterface')

    def _setup_navigation(self):
        # 主页
        self.addSubInterface(
            interface=self.homeInterface,
            icon=FluentIcon.HOME,
            text='主页',
            position=NavigationItemPosition.TOP
        )

        # 数据处理组
        self.navigationInterface.addSeparator()
        self.addSubInterface(
            interface=self.dataGeneratorInterface,
            icon=FluentIcon.EDIT,
            text='数据生成器'
        )

        # 路径规划组
        self.navigationInterface.addSeparator()
        self.addSubInterface(
            interface=self.mathInterface,
            icon=FluentIcon.CHECKBOX,
            text='象限处理'
        )
        self.addSubInterface(
            interface=self.planningInterface,
            icon=FluentIcon.IOT,
            text='路径规划'
        )
        self.addSubInterface(
            interface=self.animationInterface,
            icon=FluentIcon.MEDIA,
            text='3D动画'
        )

        # 工具组
        self.navigationInterface.addSeparator()
        self.addSubInterface(
            interface=self.batchInterface,
            icon=FluentIcon.PLAY,
            text='一键运行'
        )
        self.addSubInterface(
            interface=self.statsInterface,
            icon=FluentIcon.ALBUM,
            text='统计结果'
        )
        self.addSubInterface(
            interface=self.clearInterface,
            icon=FluentIcon.DELETE,
            text='清除数据',
            position=NavigationItemPosition.BOTTOM
        )

if __name__ == '__main__':
    app = QApplication(sys.argv)
    translator = FluentTranslator()
    app.installTranslator(translator)
    
    window = MainWindow()
    window.show()
    
    sys.exit(app.exec_())


